**************************************************
************ LOAD AND PREP CVAP DATA *************
**************************************************
* get the name of the current data file in memory
_getfilename "`c(filename)'"
local CVAP_data_set = "GRACE_CVAP_JOP_Replication_7_28_22.dta"
* if it doesn't match the CVAP data set, load the CVAP data
if "`r(filename)'" != "`CVAP_data_set'"{
    di in red "Got filename: `r(filename)', loading CVAP data set and replacing existing data set"
    use "data_files/GRACE_CVAP_JOP_Replication_7_28_22.dta", replace
}

* now we check whether we have already run the necessary replication prep code
* we do this by looking for the ballot_mmd variable
* if it doesn't exist, run CVAP prep
capture confirm variable ballot_mmd
if _rc {
    di in red "running CVAP data prep do file"
    quietly do "do_files/prep_CVAP_data/CVAP_data_prep.do"
}
else {
    di in red "already ran CVAP replication prep, continuing with the rest of the file"
} 
